package cc.magicjson.summary.errors.connection.closed.service.message.producer;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;


@Service
public class MessageProducer {

    private final JmsTemplate jmsTemplate;

    public MessageProducer(JmsTemplate jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }

    /**
     * 发送消息到指定队列
     *
     * @param destination 队列名称
     * @param message     消息内容
     */
    public void sendMessage(Destination destination, String message) {
        jmsTemplate.convertAndSend(destination, message);
        System.out.println("发送消息成功：" + message);
    }
}
